﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Drawing;
using System.IO;
using System.Windows.Media.Imaging;
using System.Drawing.Imaging;

namespace SmartWindow
{
    public class SmartButton
    {
        private ImageBrush image;
        private string appName;
        private string appPath;
        private int mode = 0;
        private Stream stream;
        private DateTime date;

        public SmartButton(string appPath)
        {
            ImageBrush ib = new ImageBrush();
            FileToImageIconConverter some = new FileToImageIconConverter(appPath);
            ImageSource imgSource = some.Icon;
            ib.ImageSource = imgSource;
            ib.Stretch = Stretch.None;

            this.appPath = appPath;
            image = ib;
            appName = System.IO.Path.GetFileNameWithoutExtension(appPath);
            date = System.IO.File.GetLastAccessTime(appPath);
            this.mode = 4;
        }

        public SmartButton(Stream stream, string name, Bitmap bitmap)
        {
            this.stream = stream;
            ImageBrush ib = new ImageBrush();
            FileToImageIconConverter some = new FileToImageIconConverter(bitmap, 0);
            ImageSource imgSource = some.Icon;
            ib.ImageSource = imgSource;
            ib.Stretch = Stretch.None;
            this.image = ib;
            appName = name;
            this.mode = 0;
        }

        public SmartButton(string name, int mode, Bitmap bitmap)
        {
            ImageBrush ib = new ImageBrush();
            FileToImageIconConverter some = new FileToImageIconConverter(bitmap, mode);
            ImageSource imgSource = some.Icon;
            ib.ImageSource = imgSource;
            ib.Stretch = Stretch.None;
            this.image = ib;
            appName = name;
            if (mode == 1) //close
            {
                this.mode = 1;
            }
            else if (mode == 2) //settings
            {
                this.mode = 2;
            }
            else if (mode == 3) // keyboard
            {
                this.mode = 3;
            }
        }

        public int getMode()
        {
            return mode;
        }

        public DateTime getDateTime()
        {
            return date;
        }

        public void setDateTime(DateTime date)
        {
            this.date = date;
        }

        public Stream getStream()
        {
            return stream;
        }

        public ImageBrush getImage()
        {
            return image;
        }

        public string getAppName()
        {
            return appName;
        }

        public string getAppPath()
        {
            return appPath;
        }
    }
}
